package com.mew.lobby.handler.friend;


import com.mew.common.exception.ResponseCode;
import com.mew.common.rest.LongMessage;
import com.mew.common.rest.bo.MewSession;
import com.mew.lobby.annotation.LobbyHandler;
import com.mew.lobby.net.LobbyHandlerMapCmdType;
import com.mew.lobby.net.MewHandler;
import com.mew.lobby.provide.FriendFeignService;
import com.zebra.remoting.protocol.ZebraCommand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author dylin
 * @create 2021/5/11
 */
@Service
@Slf4j
@LobbyHandler(LobbyHandlerMapCmdType.FriendGive)
public class FriendGiveHandler implements MewHandler<LongMessage> {
    @Autowired
    private FriendFeignService friendFeignService;


    @Override
    public void handle(ZebraCommand<LongMessage> zebraCommand, MewSession session) {
        int code=friendFeignService.give(zebraCommand.getUserId(),zebraCommand.getRequest().getL());
        if(code==ResponseCode.Success.code()){
            zebraCommand.sendMessage(zebraCommand.getRequest());
            return;
        }
        zebraCommand.sendFailureCode(code);
    }
}
